package com.company.bytedance2017;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
5
BDAC
C
ADC
CDA
BA
 */
public class First {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] lines = new String[n];
        int maxLen = 0;
        for(int i = 0; i < n; i++){
            lines[i] = sc.next();
            int len = lines[i].length();
            if(len > maxLen){
                maxLen = len;
            }
        }
        Map<Character, Integer>[] freqs = new HashMap [maxLen];
        for(int i = 0; i < maxLen; i++){
            freqs[i] = new HashMap<>();
        }
        for(int i = 0; i < n; i++){
            String line = lines[i];
            int len = line.length();
            for(int j = 0; j < len; j++){
                char c = line.charAt(j);
                Map<Character, Integer> freq = freqs[maxLen - len + j];
                if(freq.containsKey(c)){
                    freq.put(c, freq.get(c) + 1);
                }else{
                    freq.put(c, 1);
                }
            }
        }
    }

}
